home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / graphics / rand_point.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  939 b   |  52 lines

  1. #include <LEDA/window.h>
  2. #include <LEDA/stream.h>
  3.  
  4.  
  5. main()
  6. {
  7.   window W;
  8.   panel  P;
  9.  
  10.   string file_name = "points";
  11.   bool file_output = true;
  12.   int N = 100;
  13.   int max_coord = 1000;
  14.   int generator = 1;
  15.  
  16.  
  17.   P.string_item("file",file_name);
  18.   P.bool_item("file output",file_output);
  19.   P.int_item("# points",N);
  20.   P.int_item("max coord",max_coord,0,5000);
  21.   P.choice_item("generator",generator,"rand()","random()");
  22.   P.open();
  23.   
  24.   file_ostream F(file_name);
  25.  
  26.   W.init(0,max_coord,0);
  27.  
  28.   int i;
  29.  
  30.   if (generator == 1)
  31.     for (i=0; i<N ; i++)
  32.     { long x =  random() % max_coord;
  33.       long y =  random() % max_coord;
  34.       W.draw_pix(x,y);
  35.       if (file_output) F << x << " " << y << "\n";
  36.      }
  37.  
  38.   if (generator == 0)
  39.     for (i=0; i<N ; i++)
  40.     { long x =  rand() % max_coord;
  41.       long y =  rand() % max_coord;
  42.       W.draw_pix(x,y);
  43.       if (file_output) F << x << " " << y << "\n";
  44.      }
  45.  
  46.   W.read_mouse();
  47.  
  48.   return 0;
  49.  
  50. }
  51.   
  52.